package com.snowy.framework.common.base.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.snowy.framework.common.base.dto.SlicedQueryResult;

/**
 * @Description: ServiceImpl基类
 * @Author: cl
 * @Date: 2020.10.30
 * @Version: 1.0
 */
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<BaseMapper<T>, T> {

	protected BaseMapper getMapper() {
		return this.getBaseMapper();
	}

	/**
	 * 分页查询数据
	 *
	 * @param data
	 *            数据集合
	 * @return 分页对象
	 */
	protected <T> SlicedQueryResult<T> slicedQueryResult(List<T> data) {
		IPage<T> pageInfo = new Page<>();
		SlicedQueryResult<T> slicedQueryResult = new SlicedQueryResult<T>((int)pageInfo.getCurrent(), (int)pageInfo.getSize(), pageInfo.getTotal(), data);
		return slicedQueryResult;
	}
}
